<?php

namespace App\Core;

use Wonfu\Core\Database\CakeLoggingStatementWrapper;

class CarsvcCakeLoggingStatementWrapper extends CakeLoggingStatementWrapper
{
    /**
     * Copies the logging data to the passed LoggedQuery and sends it
     * to the logging system.
     *
     * @return void
     */
    protected function _log(): void
    {
        if ($this->loggedQuery === null) {
            return;
        }

        $this->loggedQuery->query = $this->queryString;
        $context = ['took' => $this->loggedQuery->took, 'numRows' => $this->loggedQuery->numRows];
        if($this->loggedQuery->took > 100){
            $context['风险sql'] = true;
        }
        $this->getLogger()->info((string)$this->loggedQuery,$context);
        if($this->logHook){
            ($this->logHook)($this->loggedQuery);
        }
        $this->loggedQuery = null;
    }


}